package com.mes.system.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Employee;
import com.mes.common.domain.BasicModel;
import com.mes.common.util.SysUtil;

@Entity()
@Table(name = "S_EMPLOYEE_ROLE")
@BatchSize(size=10)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class EmployeeRole extends BasicModel implements java.io.Serializable {

	@Id
	@GenericGenerator(name="uniqueId", strategy="assigned")
	@Column(name="UNIQUEID")
	private String uniqueId;

	@Column(name="EMPLOYEEID",length=50)
	private String employeeUid;
	
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="EMPLOYEEID",insertable=false,updatable=false)
	private Employee employee;
	
	@Column(name="ROLEID",length=50)
	private String roleUid;
	
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ROLEID",insertable=false,updatable=false)
	private Role role;

	@Column(name="ISDEFAULT",length=50)
	private Boolean isDefault;


	public EmployeeRole() {
		this.setUuid(SysUtil.getUUID());
	}

	public EmployeeRole(String employeeUid, String roleUid) {
		this.setUuid(SysUtil.getUUID());
		this.employeeUid = employeeUid;
		this.roleUid = roleUid;
	}

	public String getUuid() {
		return uniqueId;
	}

	public void setUuid(String uuid) {
		this.uniqueId = uuid;
	}
	
	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}
	
	public String getEmployeeUid() {
		return employeeUid;
	}

	public void setEmployeeUid(String employeeUid) {
		this.employeeUid = employeeUid;
	}

	public String getRoleUid() {
		return roleUid;
	}

	public void setRoleUid(String roleUid) {
		this.roleUid = roleUid;
	}

	public Boolean getIsDefault() {
		return isDefault;
	}

	public void setIsDefault(Boolean isDefault) {
		this.isDefault = isDefault;
	}

	public Employee getEmployee() {
		return employee;
	}

	public Role getRole() {
		return role;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public void setRole(Role role) {
		this.role = role;
	}
	

}